package com.snake.springboot.custom.service.impl.aicost;


import com.snake.springboot.custom.api.model.aicost.FormulaModel;
import com.snake.springboot.custom.api.response.aicost.FormulaRsp;
import com.snake.springboot.custom.api.service.aicost.FormulaService;
import com.snake.springboot.custom.dao.mybatis.entity.aicost.FormulaDO;
import com.snake.springboot.custom.dao.mybatis.mappers.aicost.FormulaMapper;
import com.snake.springboot.custom.service.assemble.aicost.FormulaAssembler;
import org.snake.common.utils.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>算力计算公式业务
 * 类{@code FormulaServiceImpl} </br>
 * 创建时间2025/3/20 16:50
 * @author yangxt
 * @see
 */
@Service
public class FormulaServiceImpl implements FormulaService {

    private FormulaMapper formulaMapper;
    @Autowired
    public FormulaServiceImpl(FormulaMapper formulaMapper) {
        this.formulaMapper = formulaMapper;
    }

    @Override
    public int update(FormulaModel model) {
        FormulaDO formulaDO = FormulaAssembler.toDO(model);
        return formulaMapper.update(formulaDO);
    }

    @Override
    public List<FormulaRsp> formulaList(FormulaModel params) {
        FormulaDO formulaDO = FormulaAssembler.toDO(params);
        List<FormulaDO> formulaDOList = formulaMapper.findByCondition(formulaDO);
        return ListUtils.copy(formulaDOList,FormulaRsp.class);
    }
}
